package com.getword.service;

import com.getword.domain.Outline;
import com.getword.web.model.Result;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Pageable;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;


@CacheConfig(cacheNames = "demo")
public interface OutlineService {
    /**
     * 获取大纲子节点
     * @param pid
     * @return
     */
    Result getChild(Long pid);

    /**
     * 将大纲从session中取出，并保存到数据库，同时保存OutlineDetail
     * @param outline :name,course,user
     * @return
     */
    Result saveOutline(Outline outline, HttpServletRequest request);


    /**
     * 修改session中的大纲信息
     * @param id
     * @param name
     * @param intro
     * @return
     */
    Result updateSessionOutline(Integer id, String name, String intro, HttpServletRequest request);
    /**
     * 大纲预览，将大纲解析并暂存到session中
     * @param file
     * @param request
     * @return
     */
    Result getOutlineData(MultipartFile file, HttpServletRequest request);

    Result checkName(Long courseId, String name);

    /**
     * 根据课程id获取大纲
     */
    Result getOutlineByCourseId(Long courseId);
    /**
     * 根据大纲id获取大纲信息
     */
    @Cacheable("demo")
    Result getOutlineById(Long id);
    /**
     * 大纲通过审核
     */
    Result pass(Long id);
    /**
     * 大纲查询
     */
    Object getOutlinePage(Pageable page, Outline outline, Long userId);

    /**
     * 随意从数据库中取出一个大纲做demo
     * @return
     */
    Result demo();

    Object getOutlinePageAllLay(Pageable pageable, Outline outline);
    Result getOutlinePageAll(Pageable pageable, Outline outline);

    /**
     * 查询所有大纲数量
     * @param outline
     * @return
     */
    Result allCount(Outline outline);

}
